const { name } = require('./package.json')
const path = require('path') //引入path模块
const contextList = ['/adminapi', '/ermsapi', '/dataarchivesapi', '/flowapi', '/formatapi', '/metadataapi']
const proxyUrl = 'http://qavue.amberdata.cn/'

const proxyObj = {}
contextList.forEach((context) => {
  proxyObj[context] = {
    target: proxyUrl,
    changeOrigin: true, //是否开启跨域
    ws: false,
  }
})

var webpack = require('webpack');
module.exports = {
  devServer: {
    open: true,
    host: 'localhost',
    port: 8080,
    https: false,
    headers: {
      'Access-Control-Allow-Origin': '*',
    },
    proxy: proxyObj,
  },
  configureWebpack: {
    plugins: [
      new webpack.ProvidePlugin({
        'window.Quill': 'quill/dist/quill.js',
        'Quill': 'quill/dist/quill.js'
      }),
    ],
    resolve: {
      alias: {
        '@': path.resolve(__dirname, 'src'),
        assets: '@/assets',
        components: '@/components',
        views: '@/views',
        common: '@/common',

      },
    },
    // output: {
    //   library: `${name}-[name]`,
    //   libraryTarget: 'umd',
    //   chunkLoadingGlobal: `webpackJsonp_${name}`,
    // },
  }
  ,
  css: {
    loaderOptions: {
      less: {
        lessOptions: {
          javascriptEnabled: true,
        },
      },
    },
  },
}